<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../Templates/InnerSystemTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>Add Sale Quotation | Merlion's ERP System</title>
    </ui:define>
    
                  
    <ui:define name="content">
        <f:view beforePhase="#{saleQuotationManagerBean.initView}">
            
            <h:form>
                <p:panel id ="panel" header ="Add New Sale Quotation">
                    <p:ajaxStatus style ="width:16px;height:16px;">
                        <f:facet name ="start">
                            <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif"/>
                        </f:facet>
                        
                        <f:facet name ="complete">
                            <h:outputText value=""/>
                        </f:facet>
                    </p:ajaxStatus>
                    
                    <p:messages />
                    
                    <h:outputLabel for="saleLeadId" style="font-weight: bold" value="Sale Lead ID:"/>
                    <p:inputText value="#{saleQuotationManagerBean.saleLeadId}" required="true" label="Sale Lead ID"
                                 requiredMessage="Sale Lead ID is required." id="saleLeadId"/>
                    <p:message for="saleLeadId"/>

                    <p:spacer height="15"/>
                    <p:dataTable var="lineItem" value="#{saleQuotationManagerBean.lineItems}"
                             dynamic="true" paginator="true" emptyMessage="No Product Type">
                        <p:column sortBy="#{lineItem.product.productType}">
                            <f:facet name="header">
                                <h:outputText value="Product Type"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.product.productType}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Price"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.product.productPrice}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Quantity"/>
                            </f:facet>
                            <h:inputText value="#{lineItem.lineItemQuantity}" />
                        </p:column>
                        
                    </p:dataTable>
                    
                    <p:commandButton id="btn" value="Save new Sale Quotation" update="panel" actionListener="#{saleQuotationManagerBean.saveSaleQuotation}" ajax="true"/>
                    <p:commandButton value="Clear" type="reset"/>
                </p:panel>
                
            </h:form>
        </f:view>
    </ui:define>

</ui:composition>
